home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DATETIME.SWG / 0025_Time and Int28.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  3KB  |  112 lines

  1. PROGRAM TestInt28;
  2.  
  3. {$M 2048,0,1024}
  4.  
  5. USES
  6.   DOS, CRT;
  7.  
  8. CONST
  9.   StatBarColor : WORD = $74;
  10.  
  11. VAR
  12.   DosIdleVec : PROCEDURE;
  13.  
  14. function Time(Hour_12 : Boolean) : String;
  15. { This function will return a string that contains the time in }
  16. { a format as follows:  HH:MM:SS am/pm or HH:MM:SS }
  17. const
  18.   am   = 'am';
  19.   pm   = 'pm';
  20.   zero = '0';
  21. var
  22.   Hour,
  23.   Minute,
  24.   Second,
  25.   Sec100 : Word;
  26.   Hr,
  27.   Min,
  28.   Sec    : String[2]; { Used in time combining }
  29. begin
  30.   GetTime(Hour, Minute, Second, Sec100); { Get the system time }
  31.   if Hour <= 12 then
  32.   begin
  33.     Str(Hour, HR);     { Convert Hour to string }
  34.     If Hour = 0 then   { Fix for MIDNIGHT }
  35.       if Hour_12 then
  36.         HR := '12'
  37.       else
  38.         HR := ' 0';
  39.   end
  40.   else
  41.   If Hour_12 then
  42.     Str(Hour - 12, HR)     { Convert Hour to string }
  43.   else
  44.     Str(Hour, HR);
  45.   if Length(Hr) = 1 then   { Fix hour for right time }
  46.     Insert(' ', HR, 1);
  47.   Str(Minute, Min);        { Convert Minute to string }
  48.   if Length(Min) = 1 then
  49.      Min := zero + Min;    { Make Min two char }
  50.   Str(Second, Sec);        { Convert Second to string }
  51.   if Length(Sec) = 1 then
  52.      Sec := zero + Sec;    { Make sec two chars }
  53.   If Hour_12 then          { We want 12 hour time }
  54.     If Hour >= 12 then
  55.       Time := Hr + ':' + Min + ':' + Sec + ' ' + pm
  56.     else
  57.       Time := Hr + ':' + Min + ':' + Sec + ' ' + am
  58.   else                                     { We want 24 hour time }
  59.     Time := Hr + ':' + Min + ':' + Sec;
  60. end;
  61.  
  62. PROCEDURE UpdateTime;
  63. VAR
  64.   TheTime  : STRING;
  65.   Row, Col : BYTE;
  66.   OldAttr  : WORD;
  67. BEGIN
  68.   ASM
  69.     mov  ah, 0Fh   { get the active display page.     }
  70.     int  10h
  71.     mov  ah, 03h   { get the cursor position.         }
  72.     int  10h       { DH = ROW, DL = COL               }
  73.     mov  Row, dh
  74.     mov  Col, dl
  75.   END;
  76.   GotoXY(69, 1);
  77.   TheTime  := Time(True);   { GET the time, write the time..   }
  78.   OldAttr  := TextAttr;     { SAVE text color.                 }
  79.   TextAttr := StatBarColor;
  80.   Write(TheTime);
  81.   TextAttr := OldAttr;      { Restore TEXT color....           }
  82.   GotoXY(Col + 1, Row + 1); { add one because BIOS starts at 0 }
  83. END;
  84.  
  85. {$F+}
  86. PROCEDURE DOSIDLE; INTERRUPT;
  87. BEGIN
  88.   UpDateTime;
  89.   INLINE($9C);  { push the flags.           }
  90.   DosIdleVec;   { call the old INT routine. }
  91. END;
  92. {$F-}
  93.  
  94. BEGIN
  95.   CheckBreak := False;           { MAKE SURE USER CANNOT PRESS      }
  96.                                  { CTRL+BREAK TO EXIT.  THE         }
  97.                                  { INTERRUPT WOULD NOT BE RESTORED. }
  98.   GetIntVec($1C, @DOSIdleVec);   { Save old interrupt vector        }
  99.   SetIntVec($1C, Addr(DOSIDLE));
  100.  
  101.   ClrScr;
  102.   TextAttr := StatBarColor;
  103.   ClrEol;
  104.   Write('TEST PROGRAM FOR hooking timer interrupt, written by Mark Klaamas ▓');
  105.   GotoXY(1, 15);
  106.   TextAttr := $07;
  107.   Write('INPUT HERE PLEASE!!!  ');
  108.   ReadLN;
  109.  
  110.   SetIntVec($1C, Addr(DOSIdleVec));     { restore old interrupt vector.    }
  111. END.
  112.